from stock_stil import comments
import requests
stock_code = 'hk01810'



def get_proxy():
    max_retries = 3
    retry = 0
    while retry < max_retries:
        response = requests.get('http://172.16.48.118:5000/get/')
        if response.status_code == 200:
            proxy = response.json()['proxy']
            return {
                'http': 'http://' + proxy,
                'https': 'http://' + proxy
            }
        retry += 1
        if retry == max_retries:
            return None


def main():
    proxy = get_proxy()
    print(proxy)
    post_list = comments.getEastMoneyPostList(
        stock_code=stock_code,
        page=1,
        proxies=proxy
    )


    print(post_list[0].__dict__)

if __name__ == '__main__':
    main()